package chapter04.exam16;
//定义Anima类
class Animal{
    public void shout(){
        System.out.println("喵喵......");
    }
}
//Dog类
class Dog extends Animal{
    //重写shout（）方法
    public void shout(){
        System.out.println("汪汪......");
    }
    public void eat(){
        System.out.println("吃骨头......");
    }
}
//定义测试类
public class exam16 {
    public static void main(String[] args) {
        Animal an = new Dog();//此时发生了向上转型，子类→父类
        Dog dog = (Dog)an;//此时发生了向下转型
        dog.shout();
        dog.eat();
    }
}
